package org.linuxgears.BouncingBall.gui;

import java.awt.Component;
import java.awt.Graphics;

import javax.swing.*;

import org.linuxgears.BouncingBall.model.Point;
import org.linuxgears.BouncingBall.painter.SimpleBallPainter;

/**
 * Created by IntelliJ IDEA.
 * User: grim
 * Date: 7 ��� 2010
 * Time: 23:22:01
 * To change this template use File | Settings | File Templates.
 */
public class BallIcon implements Icon {
    private SimpleBallPainter ballPainter;

    public BallIcon(SimpleBallPainter ballPainter) {
        this.ballPainter = ballPainter;
    }

    @Override
    public void paintIcon(Component c, Graphics g, int x, int y) {
        SimpleBallPainter bp = new SimpleBallPainter(
                ballPainter.getColor(),
                ballPainter.getSize(),
                new Point(x + ballPainter.getSize()/2, y + ballPainter.getSize()/2)
        );
        bp.paint(g);
    }

    @Override
    public int getIconWidth() {
        return ballPainter.getSize()*2;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public int getIconHeight() {
        return getIconWidth();  //To change body of implemented methods use File | Settings | File Templates.
    }
}
